// ==UserScript==
// @name         随机壁纸刷新器
// @namespace    https://api.echs.top
// @version      1.1
// @description  在img-img.lwgzs.cn页面添加左下角刷新按钮
// @author       DeepSeek
// @match        *://img-img.lwgzs.cn/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // 创建左下角悬浮按钮
    const refreshBtn = document.createElement('button');
    refreshBtn.innerHTML = "🔄 换一张";

    // 定位调整（关键修改部分）
    refreshBtn.style.position = "fixed";
    refreshBtn.style.bottom = "25px";
    refreshBtn.style.left = "25px";
    refreshBtn.style.zIndex = "9999";

    // 保留原有样式优化
    refreshBtn.style.padding = "12px 24px";
    refreshBtn.style.backgroundColor = "#2196F3";
    refreshBtn.style.color = "white";
    refreshBtn.style.border = "none";
    refreshBtn.style.borderRadius = "25px";
    refreshBtn.style.cursor = "pointer";
    refreshBtn.style.boxShadow = "0 4px 8px rgba(0,0,0,0.2)";
    refreshBtn.style.transition = "all 0.3s ease";

    // 悬停动画优化
    refreshBtn.addEventListener('mouseover', () => {
        refreshBtn.style.transform = "scale(1.1) translateX(10px)";
        refreshBtn.style.boxShadow = "0 6px 12px rgba(0,0,0,0.3)";
    });
    refreshBtn.addEventListener('mouseout', () => {
        refreshBtn.style.transform = "scale(1) translateX(0)";
        refreshBtn.style.boxShadow = "0 4px 8px rgba(0,0,0,0.2)";
    });

    // 点击处理逻辑
    refreshBtn.addEventListener('click', () => {
        // 添加防抖处理（500ms内限制重复点击）
        if(!refreshBtn.dataset.lastClick || Date.now() - refreshBtn.dataset.lastClick > 500) {
            refreshBtn.dataset.lastClick = Date.now();
            window.top.location.href = `https://api.echs.top?t=${Date.now()}`;
        }
    });

    document.body.appendChild(refreshBtn);

    // 新增加载状态指示
    GM_addStyle(`
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(0.9); }
            100% { transform: scale(1); }
        }
        button[data-loading="true"] {
            animation: pulse 1.2s infinite;
            opacity: 0.7;
        }
    `);
})();